load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")
load("@fbsource//tools/build_defs:rust_unittest.bzl", "rust_unittest")

oncall("sapling")

rust_library(
    name = "edenapi_types",
    srcs = glob(["src/**/*.rs"]),
    autocargo = {"cargo_toml_config": {
        "dependencies_override": {"dependencies": {"sapling-dag-types": {"features": ["for-tests"]}}},
        "lib": {"name": "edenapi_types"},
        "package": {
            "authors": ["Meta Source Control Team <sourcecontrol-dev@meta.com>"],
            "homepage": "https://sapling-scm.com/",
            "license": "MIT",
            "name": "sapling-edenapi_types",
            "repository": "https://github.com/facebook/sapling",
        },
    }},
    crate_root = "src/lib.rs",
    features = ["for-tests"],
    test_deps = [
        "fbsource//third-party/rust:quickcheck",
        "fbsource//third-party/rust:quickcheck_macros",
        "fbsource//third-party/rust:serde_json",
        "//common/rust/shed/quickcheck_arbitrary_derive:quickcheck_arbitrary_derive",
        "//eden/scm/lib/insta_ext:insta_ext",
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:bytes",
        "fbsource//third-party/rust:paste",
        "fbsource//third-party/rust:quickcheck",
        "fbsource//third-party/rust:serde",
        "fbsource//third-party/rust:serde_bytes",
        "fbsource//third-party/rust:serde_derive",
        "fbsource//third-party/rust:thiserror",
        ":type_macros",
        "//common/rust/shed/quickcheck_arbitrary_derive:quickcheck_arbitrary_derive",
        "//eden/scm/lib/blob:blob",
        "//eden/scm/lib/dag/dag-types:dag-types",
        "//eden/scm/lib/manifest-augmented-tree:manifest-augmented-tree",
        "//eden/scm/lib/minibytes:minibytes",
        "//eden/scm/lib/revisionstore:revisionstore_types",
        "//eden/scm/lib/types:types",
        "//eden/scm/lib/util/format-util:format-util",
    ],
)

rust_library(
    name = "type_macros",
    srcs = glob(["proc_macros/*.rs"]),
    autocargo = {
        "cargo_toml_config": {
            "lib": {"name": "type_macros"},
            "package": {
                "authors": ["Meta Source Control Team <sourcecontrol-dev@meta.com>"],
                "homepage": "https://sapling-scm.com/",
                "license": "MIT",
                "name": "sapling-type_macros",
                "repository": "https://github.com/facebook/sapling",
            },
        },
        "cargo_toml_dir": "proc_macros",
    },
    crate_root = "proc_macros/lib.rs",
    proc_macro = True,
    deps = [
        "fbsource//third-party/rust:proc-macro2",
        "fbsource//third-party/rust:quote",
        "fbsource//third-party/rust:syn1",
    ],
)

rust_unittest(
    name = "macro_test",
    srcs = ["test/basic_test.rs"],
    crate_root = "test/basic_test.rs",
    deps = [
        "fbsource//third-party/rust:quickcheck",
        "fbsource//third-party/rust:serde",
        "fbsource//third-party/rust:serde_json",
        ":edenapi_types",
        ":type_macros",
        "//common/rust/shed/quickcheck_arbitrary_derive:quickcheck_arbitrary_derive",
    ],
)
